<?php defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Code Igniter
 *
 * An open source application development framework for PHP 4.3.2 or newer
 *
 * @package		CodeIgniter
 * @author		Rick Ellis
 * @copyright	Copyright (c) 2006, pMachine, Inc.
 * @license		http://www.codeignitor.com/user_guide/license.html
 * @link			http://www.codeigniter.com
 * @since        Version 1.0
 * @filesource
 */
// ------------------------------------------------------------------------

/**
 * CodeIgniter Asset Library
 *
 * @package		CodeIgniter
 * @subpackage	Libraries
 * @category		Libraries
 * @author       Philip Sturgeon < email@philsturgeon.co.uk >
 */
class Sidebar {

	private $_ci;

	function __construct()
	{
		$this->_ci = &get_instance();
	}
	function get_today_others()
	{
		$nowTime = time();
		$todays = array();
		$sql='select p.*,s.sellername,s.sellerphone,s.selleraddress,s.sellerurl,s.sellermap,p.totalnum 
		from product p LEFT join seller s on (p.sellerid=s.id) 
		where p.begintime <= '.$nowTime.' and p.overtime > '.$nowTime.
		' and p.display = 2 ORDER BY p.order DESC,p.id ASC LIMIT 0, 3';
		$query = $this->_ci->db->query($sql);
		
		if ($query->num_rows() > 0)
		{
		   $products = $query->result();
		   foreach($products as $key => $product)
		   {
			   $product->price *= 1;
			   $product->nowprice *= 1;
			   if ($product->nowprice>0)
				{
					$product->discount = round(($product->price-$product->nowprice)/$product->price,2) * 100;
				}
				else
				{
					$product->discount = 0;
				}
				$overtime=($product->overtime);
				$product->time=$overtime-time();
				$product->num = $product->totalnum+$product->virtualnum;
				$product->success = $product->successnum-$product->num;
				$todays[] = $product;
		   }
		   return $todays;
		}
	}
}
// END Asset Class

/* End of file Asset.php */
/* Location: ./application/libraries/Asset.php */